package com.wingsfrog.travel.modules.dao;

import com.wingsfrog.travel.modules.entity.TeamInfo;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

/**
 * Created by rankin on 16/3/30.
 */
public interface TeamDao extends CrudRepository<TeamInfo, Integer> {
    @Query("select t from TeamInfo t where t.existMemberNum < t.maxMember and t.mainTaskId = ?1 ")
    public TeamInfo findFulllessTeam(Integer mainTaskId);

    @Query("select ti from TeamInfo ti ,UserTeamRel utr  where  ti.id = utr.teamId and ti.mainTaskId = ?2 and utr.userId = ?1")
    public TeamInfo findByUserIdAndMainTaskId(Integer userId, Integer mainTaskId);

    public List<TeamInfo> findByMainTaskId(Integer mainTaskId);
}
